var selectedDataRow = '';
var isInit = true;

$(function () {
    window.actionEvents = {
        'click .infoView': function(e, value, row, index) {
            //编辑操作
            selectedDataRow = row;
            openInfoGroupPage();
        },
    }
    laydate.render({
        elem: '#beginTimeStr'
        ,done: function(value, date, endDate){
            //控件选择完毕后的回调
            //点击日期、清空、现在、确定均会触发。回调返回三个参数，分别代表：生成的值、日期时间对象、结束的日期时间对象
            // setAge(value);
        }
    });
});

function doRefresh() {
    selectedDataRow = '';
    var groupTag = $('#groupTag').val();
    var status = $('#status').val();
    var dataStatus = $('#dataStatus').val();
    var beginTimeStr = $('#beginTimeStr').val();
    $('#dataTable').bootstrapTable('refresh', {
        url: basePath + 'bizUserDataGroup/pageFindUserDataGroupData?t=' + new Date().getTime(),
        query: {
            groupTag : groupTag,
            status : status,
            dataStatus : dataStatus,
            beginTimeStr : beginTimeStr,
        },
    });
}

function getParams(params) {
    var groupTag = $('#groupTag').val();
    var status = $('#status').val();
    var dataStatus = $('#dataStatus').val();
    var beginTimeStr = $('#beginTimeStr').val();
    var pageSize = params.pageSize;
    var pageNo = params.pageNumber;
    if (isInit) {
        isInit = false;
        pageSize = searchInfo.pageSize ? searchInfo.pageSize : params.pageSize;
        pageNo = searchInfo.pageNo ? searchInfo.pageNo : params.pageNumber;
    }
    return {
        groupTag : groupTag,
        status : status,
        dataStatus : dataStatus,
        beginTimeStr : beginTimeStr,
        pageSize : pageSize,
        pageNo : pageNo
    };
}

function openInfoGroupPage() {
    if (!selectedDataRow || selectedDataRow == '') {
        toastr.error(common_no_choose_msg.format("操作"));
        return;
    }
    openPage('info', selectedDataRow.id);
}

function openPage(type, id) {
    var tableOptions = $('#dataTable').bootstrapTable('getOptions', null);
    window.location.href = basePath + 'bizUserDataGroup/openEditUserDataGroupPage?&id=' + id + '&type=' + type + '&t=' + new Date().getTime() +
    '&' + $('#searchForm').serialize() + '&pageNo=' + tableOptions.pageNumber + '&pageSize=' + tableOptions.pageSize;
}

function doExport() {
    $('#searchForm').attr("action",basePath+"bizUserDataGroup/exportDataExcel");
    $('#searchForm').submit();
}

//------------------------------------------------------------------------列表数据初始化

function formatStatus(value, row, index) {
    if (!value || value == '') {
        return '';
    }
    return statusMap[value];
}

//------------------------------------------------------------------------列表选中事件
//上边选中事件
$("#dataTable").on("click-row.bs.table",function(e,row,ele){
    $("#dataTable .success").removeClass("success");
    $(ele).addClass("success");
    selectedDataRow = row;
});
